[Pages] Stub child_process.execSync directly in validation-helpers test - #133
Merged
Priyanshu Agrawal (priyanshu92) merged 1 commit intoApr 29, 2026
Conversation
Follow-up to #132. The initial test stubbed `child_process` by swapping the entry in `require.cache`, which relies on Node's caching of built-in modules — implementation detail that may not hold across versions. Switch to monkeypatching `childProcess.execSync` directly before requiring `validation-helpers.js`, with cleanup via `t.after()`. This exercises the helper through its real `require('child_process')` call and is the idiomatic node:test approach. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copilot started reviewing on behalf of
Priyanshu Agrawal (priyanshu92)
April 29, 2026 11:49
View session
Contributor
There was a problem hiding this comment.
Pull request overview
Updates the Power Pages Node test for getAuthToken to mock child_process.execSync in a more idiomatic and Node-version-stable way, avoiding reliance on require.cache behavior for built-in modules.
Changes:
- Replace built-in module stubbing via
require.cachewith direct monkeypatching ofchild_process.execSync. - Ensure cleanup via
t.after()and force a clean reload ofvalidation-helpers.jsaround the patch.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Priyanshu Agrawal (priyanshu92)
enabled auto-merge (squash)
April 29, 2026 12:05
amitjoshi438
approved these changes
Apr 29, 2026
Priyanshu Agrawal (priyanshu92)
deleted the
users/priyanshuag/fix-validation-helpers-test-stub
branch
April 29, 2026 12:05
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-up to #132 addressing copilot review feedback that arrived right around the time #132 was squash-merged (the fix commit landed on the branch but missed the merge).
The initial test in #132 stubbed
child_processby swapping the entry inrequire.cache. Node treats built-in modules as native and the cache behavior for them is an implementation detail — works on current Node but not guaranteed across versions, and not the idiomatic node:test approach.This PR switches to monkeypatching
childProcess.execSyncdirectly before requiringvalidation-helpers.js, with cleanup viat.after(). The helper is now exercised through its realrequire('child_process')call.plugins/power-pages/scripts/tests/validation-helpers.test.js(+18 / -26)Test plan
node --test plugins/power-pages/scripts/tests/validation-helpers.test.jspassesnode --test plugins/power-pages/scripts/tests/full suite stays green (141/141 locally)🤖 Generated with Claude Code